package com.dhl.rabbitmq.eight;

import com.dhl.rabbitmq.utils.RabbitConstant;
import com.dhl.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.util.HashMap;
import java.util.Map;

import static com.dhl.rabbitmq.utils.RabbitConstant.DEAD_ROUTING_KEY;
import static com.dhl.rabbitmq.utils.RabbitConstant.NORMAL_ROUTING_KEY;

/**
 * @author danghailiang
 * 死信实战 消费者
 */
public class Consumer02 {
    /**
     * 死信队列名称
     */
    public static final String DEAD_QUEUE = "dead_queue";
    public static void main(String[] args) throws Exception {
        // 获取信道
        Channel channel = RabbitUtils.getChannel();
        // 接受消息
        System.out.println("等待接收消息.....");
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody(), "UTF-8");
            System.out.println("Consumer02 接收到消息"+message);
        };
        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, consumerTag -> {
        });
    }
}
